<template>
  <div class="shopList" style="margin:24px 24px 0 24px;">
    <div class="disFlex Flex-middle search shadow">
      <Form
        :model="formItem"
        :label-width="120"
        style="display:flex;flex-direction:row;align-items:center;flex-flow:wrap;height: 100px;"
        class="searchForm"
      >
        <FormItem label="职位名称">
          <Input v-model="formItem.jobName" placeholder="请输入职位名称" style="width:150px"/>
        </FormItem>
        <FormItem label="企业名称/ID">
          <Input v-model="formItem.conpanyName" placeholder="请输入企业名称/ID" style="width:150px"/>
        </FormItem>
        <FormItem label="投递状态">
          <Select v-model="formItem.applyStatus" style="width:150px">
            <Option value="1">待查看</Option>
            <Option value="2">已查看</Option>
          </Select>
        </FormItem>
        <FormItem label="投递时间">
          <Row>
            <Col span="11">
              <DatePicker type="date" placeholder="请选择开始时间" v-model="formItem.searchDataBegin"></DatePicker>
            </Col>
            <Col span="2" style="text-align: center">-</Col>
            <Col span="11">
              <DatePicker type="date" placeholder="请选择结束时间" v-model="formItem.searchDataFinish"></DatePicker>
            </Col>
          </Row>
        </FormItem>
        <FormItem>
          <Button type="primary" @click="searchData">搜索</Button>
        </FormItem>
      </Form>
    </div>
    <TableList
      :columns="columns"
      :data="data"
      :page="page"
      :total="pageTotal*pageNum"
      :pageNum="pageNum"
      newOne
      @newOneFn="newOne"
      @changePage="changePage"
    ></TableList>
    <Modal title="Title" v-model="modal10" width="800" class-name="vertical-center-modal">
      <div style="min-height:200px;">
        <Table
          :columns="detailCol"
          :data="detailData"
          style="max-height:400px;overflow-y:scroll;"
          class="detailTable"
        ></Table>
      </div>
    </Modal>
  </div>
</template>

<script>
import TableList from "@/components/consumer/tableList";
import { WorkderApplyList } from "api/recuit/resume";

export default {
  name: "",
  data() {
    return {
      formItem: {
        jobName: "",
        conpanyName: "",
        applyStatus: 1,
        searchType: "timeCreate",
        searchDataBegin: "",
        searchDataFinish: ""
      },
      applyType: ["待查看", "已查看"],
      columns: [
        {
          title: "职位名称",
          key: "position_title"
        },
        {
          title: "企业名称",
          key: "title"
        },
        {
          title: "薪资范围（元）",
          key: "salary",
          render: (h, params) => {
            return h(
              "span",
              {
                style: {
                  marginLeft: "15px"
                }
              },
              params.row.salary_min + "~" + params.row.salary_max
            );
          }
        },
        {
          title: "投递状态",
          key: "apply",
          render: (h, params) => {
            return h(
              "span",
              {
                style: {
                  marginLeft: "15px"
                }
              },
              this.applyType[params.row.apply_status - 1]
            );
          }
        },
        {
          title: "投递时间",
          key: "time_create"
        },
        {
          title: "操作",
          key: "action",
          width: 250,
          align: "center",
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "primary",
                    size: "middle"
                  },
                  style: {
                    margin: "0 2px"
                  },
                  on: {
                    click: () => {
                      // this.show(params.index);
                    }
                  }
                },
                "查看职位"
              )
            ]);
          }
        }
      ],

      data: [],
      detailCol: [
        {
          title: "操作时间",
          key: "time"
        },
        {
          title: "操作名称",
          key: "name"
        },
        {
          title: "本次充值",
          key: "nowCash"
        },
        {
          title: "累计充值",
          key: "allCash"
        }
      ],
      detailData: [
        {
          name: "John Brown",
          nowCash: 18,
          allCash: 200,
          time: "2016-10-03"
        },
        {
          name: "John Brown",
          nowCash: 18,
          allCash: 200,
          time: "2016-10-03"
        },
        {
          name: "John Brown",
          nowCash: 18,
          allCash: 200,
          time: "2016-10-03"
        },
        {
          name: "John Brown",
          nowCash: 18,
          allCash: 200,
          time: "2016-10-03"
        },
        {
          name: "John Brown",
          nowCash: 18,
          allCash: 200,
          time: "2016-10-03"
        },
        {
          name: "John Brown",
          nowCash: 18,
          allCash: 200,
          time: "2016-10-03"
        },
        {
          name: "John Brown",
          nowCash: 18,
          allCash: 200,
          time: "2016-10-03"
        },
        {
          name: "John Brown",
          nowCash: 18,
          allCash: 200,
          time: "2016-10-03"
        }
      ],
      modal10: false,
      page: 0,
      pageNum: 9, //显示条数
      jobSum: 0, //职位总数
      auditStatus: 1, //查询状态
      pageTotal: 0 //页面总数
    };
  },
  components: {
    TableList
  },

  mounted() {
    let userSaasId = this.$route.params.userSaasId
    this.userSaasId = userSaasId
    this.getData();
  },

  methods: {
    //切换页面
    changePage(data) {
      let { page } = data;
      this.page = --page;
      this.getData();
    },
    //条件查询
    searchData() {
      this.page = 0;
      this.getData();
    },
    //获取数据
    getData() {
      let page = this.page;
      let pageNum = this.pageNum;
      let formItem = this.formItem;
      let dataList = new Object();
      dataList.page = ++page;
      dataList.pageNum = pageNum;
      dataList.userSaasId = this.userSaasId;
      //获取查询条件
      for (let i in formItem) {
        dataList[i] = formItem[i];
      }
      //时间段转换成时间戳
      dataList.searchDataBegin = dataList.searchDataBegin.valueOf() / 1000;
      dataList.searchDataFinish = dataList.searchDataFinish.valueOf() / 1000;

      WorkderApplyList(dataList).then(res => {
        let { jobApplyList, jobApplyCount, page } = res;
        this.data = jobApplyList;
        this.companySum = jobApplyCount;
        this.pageTotal = page.pageTotal;
        this.page = Number(page.page)
      });
    }
  }
};
</script>

<style scoped lang="less">
/*表头标题*/
.table-header-title {
  height: 100%;
  padding: 0 18px;
  box-sizing: border-box;
}

/*表头提示图标*/
.table-header-icon {
  font-size: 20px;
  margin-left: 10px;
}

/*弹窗标题*/
.alert-title {
  margin-top: 10px;
}

/*搜索*/
.search {
  padding: 18px;
  box-sizing: border-box;
  background: #fff;
  margin-bottom: 24px;
}

/*搜索下拉*/
.search-select {
  min-width: 128px;
  width: 128px;
  margin-right: 15px;
}

/*搜索输入框*/
.search-input {
  margin-right: 15px;
  top: 0;
}

.search-button {
  /* width: 80px;
    min-width: 80px; */
  margin-left: 15px;
}
.timeSpan {
  margin: 0 15px;
}
.detailTable::-webkit-scrollbar {
  width: 15px;
}
.detailTable tr {
  width: 700px;
}
.searchForm {
  .ivu-form-item {
    margin-bottom: 0;
  }
}
</style>
